DESCRIPCIÓN DEL PROBLEMA

HIPOTESIS

CARGA Y DEPURACION DE DATOS

Carga de Datos

Datos de 2014

raw_data_2014 <- read.csv(file="./data/Accidentalidad_georreferenciada_2014.csv", encoding="UTF-8", header=TRUE, sep=",")
head(raw_data_2014)
##   X.U.FEFF.OBJECTID        X       Y RADICADO                    FECHA
## 1            211279 831190.1 1179690  1423828 2014-01-01T00:00:00.000Z
## 2            211280 835013.6 1184224  1423839 2014-01-01T00:00:00.000Z
## 3            211281 837032.7 1184750  1423840 2014-01-01T00:00:00.000Z
## 4            211282 830649.5 1181383  1423849 2014-01-01T00:00:00.000Z
## 5            211283 833740.8 1188644  1423890 2014-01-01T00:00:00.000Z
## 6            211284 836425.4 1186933  1423892 2014-01-01T00:00:00.000Z
##       HORA DIA PERIODO             CLASE    DIRECCION
## 1 02:20 AM   1    2014            Choque   CR 80 CL 8
## 2 12:50 AM   1    2014         Atropello  CR 53 CL 61
## 3 01:00 AM   1    2014         Atropello  CR 39 CL 70
## 4 12:37 AM   1    2014         Atropello  CL 32 CR 84
## 5 10:40 AM   1    2014 Caída de Ocupante CR 80 CL 101
## 6 04:00 AM   1    2014            Choque  CR 48 CL 93
##              DIRECCION_ENC CBML                    TIPO_GEOCOD GRAVEDAD
## 1 CR  080   008  000 00000 1611 Malla vial aproximada: CR 81-7   HERIDO
## 2 CR  053   061  000 00000 1003                     Malla vial   HERIDO
## 3 CR  039   070  000 00000 0308                     Malla vial   HERIDO
## 4 CL  032   084  000 00000 1617                     Malla vial   HERIDO
## 5 CR  080   101  000 00000 0603                     Malla vial   HERIDO
## 6 CR  048   093  000 00000 0401                     Malla vial   HERIDO
##                 BARRIO          COMUNA       DISENO DIA_NOMBRE MES
## 1   Loma de los Bernal           Belén Tramo de via  MIÉRCOLES   1
## 2       Jesús Nazareno   La Candelaria Tramo de via  MIÉRCOLES   1
## 3    Manrique Oriental        Manrique Tramo de via  MIÉRCOLES   1
## 4         Las Mercedes           Belén Tramo de via  MIÉRCOLES   1
## 5 Doce de Octubre No.2 Doce de Octubre Tramo de via  MIÉRCOLES   1
## 6               Berlin        Aranjuez Interseccion  MIÉRCOLES   1
summary(raw_data_2014)
##  X.U.FEFF.OBJECTID       X                Y              RADICADO        
##  Min.   :211279    Min.   :823074   Min.   :1172279   Min.   :3.800e+01  
##  1st Qu.:222939    1st Qu.:833036   1st Qu.:1181405   1st Qu.:1.436e+06  
##  Median :234284    Median :834331   Median :1183250   Median :1.447e+06  
##  Mean   :234276    Mean   :834150   Mean   :1183303   Mean   :4.810e+15  
##  3rd Qu.:245700    3rd Qu.:835417   3rd Qu.:1185597   3rd Qu.:1.459e+06  
##  Max.   :257033    Max.   :845503   Max.   :1189981   Max.   :5.002e+19  
##                                                                          
##                       FECHA             HORA            DIA       
##  2014-06-03T00:00:00.000Z:  168   04:00 PM:  776   Min.   : 1.00  
##  2014-02-13T00:00:00.000Z:  163   06:00 PM:  768   1st Qu.: 8.00  
##  2014-08-06T00:00:00.000Z:  163   05:00 PM:  766   Median :16.00  
##  2014-08-08T00:00:00.000Z:  158   02:00 PM:  705   Mean   :15.73  
##  2014-05-19T00:00:00.000Z:  157   03:00 PM:  695   3rd Qu.:23.00  
##  2014-07-07T00:00:00.000Z:  157   01:00 PM:  679   Max.   :31.00  
##  (Other)                 :40628   (Other) :37205                  
##     PERIODO                   CLASE               DIRECCION    
##  Min.   :2014   Atropello        : 4779   CR 64 C CL 78:  230  
##  1st Qu.:2014   Caída de Ocupante: 4157   CR 1 CL 1    :  165  
##  Median :2014   Choque           :27157   CR 64 C CL 67:  151  
##  Mean   :2014   Incendio         :    8   CR 57 CL 44  :  118  
##  3rd Qu.:2014   Otro             : 4521   CR 80 CL 50  :  115  
##  Max.   :2014   Volcamiento      :  972   CR 80 CL 65  :  115  
##                                           (Other)      :40700  
##                     DIRECCION_ENC        CBML      
##  CR  064 C   078  000 00000:  248   1019   : 1148  
##  CR  001   001  000 00000  :  165   0517   :  979  
##  CR  064 C   067  000 00000:  151   1507   :  783  
##  CR  057   044  000 00000  :  118   1012   :  774  
##  CR  080   065  000 00000  :  116   1007   :  733  
##  CR  080   050  000 00000  :  115   1105   :  733  
##  (Other)                   :40681   (Other):36444  
##                         TIPO_GEOCOD          GRAVEDAD    
##  Malla vial                   :30320   HERIDO    :23077  
##  Malla vial cruce invertido   : 2251   MUERTO    :  256  
##  EPM sin Interior             :  987   SOLO DAÑOS:18261  
##  EPM con Interior             :  435                     
##  Malla vial aproximada: CR 1-2:  167                     
##  ZONA RURAL                   :   97                     
##  (Other)                      : 7337                     
##                 BARRIO                   COMUNA                DISENO     
##  La Candelaria     : 1151   La Candelaria   : 8760   Tramo de via :33745  
##  Caribe            :  980   Laureles Estadio: 4678   Interseccion : 5305  
##  Campo Amor        :  786   Castilla        : 4204   Lote o Predio: 1083  
##  Perpetuo Socorro  :  775   El Poblado      : 3154   Glorieta     :  702  
##  Los Conquistadores:  735   Guayabal        : 2946                :  256  
##  Guayaquil         :  733   Robledo         : 2828   Ciclo Ruta   :  192  
##  (Other)           :36434   (Other)         :15024   (Other)      :  311  
##      DIA_NOMBRE        MES        
##  DOMINGO  :4209   Min.   : 1.000  
##  JUEVES   :6143   1st Qu.: 4.000  
##  LUNES    :6008   Median : 7.000  
##  MARTES   :6301   Mean   : 6.543  
##  MIÉRCOLES:6420   3rd Qu.: 9.000  
##  SÁBADO   :5984   Max.   :12.000  
##  VIERNES  :6529
str(raw_data_2014)
## 'data.frame':    41594 obs. of  19 variables:
##  $ X.U.FEFF.OBJECTID: int  211279 211280 211281 211282 211283 211284 211285 211286 211287 211288 ...
##  $ X                : num  831190 835014 837033 830649 833741 ...
##  $ Y                : num  1179690 1184224 1184750 1181383 1188644 ...
##  $ RADICADO         : num  1423828 1423839 1423840 1423849 1423890 ...
##  $ FECHA            : Factor w/ 365 levels "2014-01-01T00:00:00.000Z",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ HORA             : Factor w/ 967 levels "01:00 AM","01:00 PM",..: 95 954 1 938 777 201 469 268 37 72 ...
##  $ DIA              : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ PERIODO          : int  2014 2014 2014 2014 2014 2014 2014 2014 2014 2014 ...
##  $ CLASE            : Factor w/ 6 levels "Atropello","Caída de Ocupante",..: 3 1 1 1 2 3 3 3 3 2 ...
##  $ DIRECCION        : Factor w/ 12673 levels "CL 1 A CR 42",..: 11441 8871 6987 1424 11297 8063 3081 6269 11142 8131 ...
##  $ DIRECCION_ENC    : Factor w/ 12510 levels "000","CL     029  000 00000",..: 11024 8642 6786 915 11166 7817 2469 6072 10863 7898 ...
##  $ CBML             : Factor w/ 391 levels "","0101","01010480009",..: 333 192 39 340 105 48 170 176 241 280 ...
##  $ TIPO_GEOCOD      : Factor w/ 2252 levels "Catastro con Interior",..: 2064 5 5 5 5 5 5 5 5 5 ...
##  $ GRAVEDAD         : Factor w/ 3 levels "HERIDO","MUERTO",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ BARRIO           : Factor w/ 313 levels "","6001","Aguas Frias",..: 181 129 201 175 81 40 31 155 294 302 ...
##  $ COMUNA           : Factor w/ 24 levels "","Aranjuez",..: 4 16 18 4 11 2 5 5 17 12 ...
##  $ DISENO           : Factor w/ 13 levels "","Ciclo Ruta",..: 11 11 11 11 11 4 11 4 11 11 ...
##  $ DIA_NOMBRE       : Factor w/ 7 levels "DOMINGO  ","JUEVES   ",..: 5 5 5 5 5 5 5 5 5 5 ...
##  $ MES              : int  1 1 1 1 1 1 1 1 1 1 ...
levels(raw_data_2014$CLASE)
## [1] "Atropello"         "Caída de Ocupante" "Choque"           
## [4] "Incendio"          "Otro"              "Volcamiento"
levels(raw_data_2014$CLASE) <- c("Atropello","Caida_Ocupante","Choque","Incendio","Otro",
                                 "Volcamiento")
levels(raw_data_2014$CLASE)
## [1] "Atropello"      "Caida_Ocupante" "Choque"         "Incendio"      
## [5] "Otro"           "Volcamiento"

Datos de 2015

raw_data_2015 <- read.csv(file="./data/Accidentalidad_georreferenciada_2015.csv", encoding="UTF-8", header=TRUE, sep=",")
head(raw_data_2015)
##   X.U.FEFF.OBJECTID        X       Y RADICADO                    FECHA
## 1              1001 835766.9 1183119  1471803 2015-01-13T00:00:00.000Z
## 2              1002 839496.9 1177763  1471804 2015-01-13T00:00:00.000Z
## 3              1003 832970.8 1178867  1471805 2015-01-13T00:00:00.000Z
## 4              1004 831318.1 1187204  1471806 2015-01-13T00:00:00.000Z
## 5              1005 833710.7 1185631  1471807 2015-01-13T00:00:00.000Z
## 6              1006 839496.9 1177763  1471808 2015-01-12T00:00:00.000Z
##       HORA DIA PERIODO       CLASE       DIRECCION
## 1 02:20 PM  13    2015 Volcamiento     CR 43 CL 54
## 2 09:00 AM  13    2015        Otro       CR 1 CL 1
## 3 10:00 AM  13    2015 Volcamiento    CR 58 D CL 3
## 4 06:30 PM  13    2015        Otro CL 68 B CR 96 E
## 5 05:40 AM  13    2015        Otro     CR 68 CL 70
## 6 09:30 AM  12    2015 Volcamiento       CR 1 CL 1
##                  DIRECCION_ENC CBML                     TIPO_GEOCOD
## 1     CR  043   054  000 00000 1016                      Malla vial
## 2     CR  001   001  000 00000 9086   Malla vial aproximada: CR 1-2
## 3   CR  058 D   003  000 00000 1507  Malla vial aproximada: CR 58-4
## 4 CL  068 B   096 E  000 00000 0724 Malla vial aproximada: CL 68-95
## 5     CR  068   070  000 00000 0519 Malla vial aproximada: CR 69-71
## 6     CR  001   001  000 00000 9086   Malla vial aproximada: CR 1-2
##   GRAVEDAD            BARRIO                       COMUNA       DISENO
## 1   HERIDO            Boston                La Candelaria Tramo de via
## 2   HERIDO Suburbano El Plan Corregimiento de Santa Elena Tramo de via
## 3   HERIDO        Campo Amor                     Guayabal Tramo de via
## 4   HERIDO        Monteclaro                      Robledo Tramo de via
## 5   HERIDO       El Progreso                     Castilla Tramo de via
## 6   HERIDO Suburbano El Plan Corregimiento de Santa Elena Tramo de via
##   DIA_NOMBRE MES
## 1  MARTES      1
## 2  MARTES      1
## 3  MARTES      1
## 4  MARTES      1
## 5  MARTES      1
## 6  LUNES       1
summary(raw_data_2015)
##  X.U.FEFF.OBJECTID       X                Y              RADICADO        
##  Min.   :    1     Min.   :821476   Min.   :1172359   Min.   :3.270e+02  
##  1st Qu.:11558     1st Qu.:833029   1st Qu.:1181443   1st Qu.:1.482e+06  
##  Median :23149     Median :834305   Median :1183204   Median :1.494e+06  
##  Mean   :23110     Mean   :834102   Mean   :1183264   Mean   :2.175e+16  
##  3rd Qu.:34664     3rd Qu.:835387   3rd Qu.:1185476   3rd Qu.:1.506e+06  
##  Max.   :46172     Max.   :842417   Max.   :1193451   Max.   :5.002e+20  
##                                                                          
##                       FECHA             HORA            DIA       
##  2015-08-18T00:00:00.000Z:  183   07:00 AM:  951   Min.   : 1.00  
##  2015-08-28T00:00:00.000Z:  183   08:00 AM:  921   1st Qu.: 8.00  
##  2015-09-11T00:00:00.000Z:  162   10:00 AM:  801   Median :16.00  
##  2015-12-07T00:00:00.000Z:  161   07:30 AM:  767   Mean   :15.74  
##  2015-09-17T00:00:00.000Z:  160   06:30 AM:  756   3rd Qu.:23.00  
##  2015-09-18T00:00:00.000Z:  160   06:00 AM:  741   Max.   :31.00  
##  (Other)                 :41071   (Other) :37143                  
##     PERIODO                   CLASE               DIRECCION    
##  Min.   :2015   Choque           :28249   CR 64 C CL 78:  211  
##  1st Qu.:2015   Atropello        : 4485   CR 63 CL 44  :  177  
##  Median :2015   Otro             : 4218   CR 57 CL 44  :  172  
##  Mean   :2015   Caida Ocupante   : 3673   CR 64 C CL 67:  132  
##  3rd Qu.:2015   Volcamiento      : 1435   CR 80 CL 50  :  122  
##  Max.   :2015   Caída de Ocupante:   18   CR 52 CL 10  :  121  
##                 (Other)          :    2   (Other)      :41145  
##                     DIRECCION_ENC        CBML      
##  CR  064 C   078  000 00000:  227   1019   : 1067  
##  CR  063   044  000 00000  :  177   0517   :  899  
##  CR  057   044  000 00000  :  173   1007   :  882  
##  CR  064 C   067  000 00000:  132   1006   :  867  
##  CR  080   050  000 00000  :  122   1012   :  804  
##  CR  052   010  000 00000  :  121   1105   :  783  
##  (Other)                   :41128   (Other):36778  
##                           TIPO_GEOCOD          GRAVEDAD    
##  Malla vial                     :31011   HERIDO    :23273  
##  Malla vial cruce invertido     : 2341   MUERTO    :  250  
##  EPM sin Interior               :  886   SOLO DAÑOS:18557  
##  EPM con Interior               :  459                     
##  Malla vial aproximada: CR 1-2  :   86                     
##  Malla vial aproximada: CR 65-80:   85                     
##  (Other)                        : 7212                     
##                 BARRIO                   COMUNA                DISENO     
##  La Candelaria     : 1069   La Candelaria   : 9355   Tramo de via :33729  
##  Caribe            :  899   Laureles Estadio: 4908   Interseccion : 5794  
##  Guayaquil         :  883   Castilla        : 4000   Lote o Predio: 1219  
##  San Benito        :  868   El Poblado      : 3194   Glorieta     :  751  
##  Perpetuo Socorro  :  804   Robledo         : 2884                :  250  
##  Los Conquistadores:  785   Guayabal        : 2814   Paso Elevado :  101  
##  (Other)           :36772   (Other)         :14925   (Other)      :  236  
##      DIA_NOMBRE        MES        
##  DOMINGO  :4048   Min.   : 1.000  
##  JUEVES   :6516   1st Qu.: 4.000  
##  LUNES    :5973   Median : 7.000  
##  MARTES   :6696   Mean   : 6.624  
##  MIÉRCOLES:6341   3rd Qu.:10.000  
##  SÁBADO   :6003   Max.   :12.000  
##  VIERNES  :6503
str(raw_data_2015)
## 'data.frame':    42080 obs. of  19 variables:
##  $ X.U.FEFF.OBJECTID: int  1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 ...
##  $ X                : num  835767 839497 832971 831318 833711 ...
##  $ Y                : num  1183119 1177763 1178867 1187204 1185631 ...
##  $ RADICADO         : num  1471803 1471804 1471805 1471806 1471807 ...
##  $ FECHA            : Factor w/ 365 levels "2015-01-01T00:00:00.000Z",..: 13 13 13 13 13 12 13 13 13 13 ...
##  $ HORA             : Factor w/ 898 levels "01:00 AM","01:00 PM",..: 103 610 691 413 342 651 560 493 342 868 ...
##  $ DIA              : int  13 13 13 13 13 12 13 13 13 13 ...
##  $ PERIODO          : int  2015 2015 2015 2015 2015 2015 2015 2015 2015 2015 ...
##  $ CLASE            : Factor w/ 8 levels "","Atropello",..: 8 7 8 7 7 8 7 7 7 4 ...
##  $ DIRECCION        : Factor w/ 12729 levels "CL 1 A CR 35",..: 7461 5630 9229 4297 10332 5630 9640 10693 9766 9166 ...
##  $ DIRECCION_ENC    : Factor w/ 12523 levels "000","CL     010  000 00000",..: 7057 5546 8947 3700 9999 5546 9515 10334 9266 8875 ...
##  $ CBML             : Factor w/ 394 levels "","0","0101",..: 217 389 317 150 106 389 85 133 232 200 ...
##  $ TIPO_GEOCOD      : Factor w/ 2229 levels "Catastro con Interior",..: 5 1014 1645 797 1844 1014 1728 1892 5 5 ...
##  $ GRAVEDAD         : Factor w/ 3 levels "HERIDO","MUERTO",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ BARRIO           : Factor w/ 319 levels "","0","6001",..: 51 283 62 210 99 283 170 76 194 248 ...
##  $ COMUNA           : Factor w/ 26 levels "","0","Aranjuez",..: 18 12 15 22 7 12 7 22 19 18 ...
##  $ DISENO           : Factor w/ 13 levels "","Ciclo Ruta",..: 11 11 11 11 11 11 11 11 11 11 ...
##  $ DIA_NOMBRE       : Factor w/ 7 levels "DOMINGO  ","JUEVES   ",..: 4 4 4 4 4 3 4 4 4 4 ...
##  $ MES              : int  1 1 1 1 1 1 1 1 1 1 ...
levels(raw_data_2015$CLASE)
## [1] ""                  "Atropello"         "Caída de Ocupante"
## [4] "Caida Ocupante"    "Choque"            "Incendio"         
## [7] "Otro"              "Volcamiento"
levels(raw_data_2015$CLASE) <- c("Otro","Atropello","Caida_Ocupante","Caida_Ocupante","Choque",
                                 "Incendio","Otro","Volcamiento")
levels(raw_data_2015$CLASE)
## [1] "Otro"           "Atropello"      "Caida_Ocupante" "Choque"        
## [5] "Incendio"       "Volcamiento"

Datos 2016

raw_data_2016 <- read.csv(file="./data/Accidentalidad_georreferenciada_2016.csv", encoding="UTF-8", header=TRUE, sep=",")
head(raw_data_2016)
##   X.U.FEFF.OBJECTID        X       Y RADICADO                    FECHA
## 1            259034 827277.9 1175177  1519832 2016-01-20T00:00:00.000Z
## 2            259035 835105.9 1183570  1519765 2016-01-20T00:00:00.000Z
## 3            259036 834811.1 1182025  1519752 2016-01-20T00:00:00.000Z
## 4            259037 836020.8 1178803  1519682 2016-01-20T00:00:00.000Z
## 5            259038 832264.6 1185704  1519685 2016-01-20T00:00:00.000Z
## 6            259040 831843.3 1183130  1519883 2016-01-20T00:00:00.000Z
##       HORA DIA PERIODO       CLASE         DIRECCION
## 1 11:00 AM  20    2016      Choque CR 55 CL 48 A Sur
## 2 01:25 PM  20    2016      Choque       CL 54 CR 51
## 3 02:35 PM  20    2016      Choque       CR 46 CL 40
## 4 08:40 AM  20    2016      Choque     CR 30 CL 10 C
## 5 10:30 AM  20    2016 Volcamiento       CR 80 CL 64
## 6 10:45 AM  20    2016      Choque       CR 78 CL 44
##                 DIRECCION_ENC CBML                     TIPO_GEOCOD
## 1 CR  055  S 048 A  000 00000 8000                      Malla vial
## 2    CL  054   051  000 00000 1005                      Malla vial
## 3    CR  046   040  000 00000 1013                      Malla vial
## 4  CR  030   010 C  000 00000 1407                      Malla vial
## 5    CR  080   064  000 00000 0705 Malla vial aproximada: CR 80-65
## 6    CR  078   044  000 00000 1112                      Malla vial
##     GRAVEDAD                        BARRIO
## 1 SOLO DAÑOS Cabecera San Antonio de Prado
## 2 SOLO DAÑOS                Estación Villa
## 3 SOLO DAÑOS                  Barrio Colón
## 4 SOLO DAÑOS                Las Lomas No.2
## 5 SOLO DAÑOS Facultad de Minas U. Nacional
## 6 SOLO DAÑOS                  El Velódromo
##                                  COMUNA        DISENO DIA_NOMBRE MES
## 1 Corregimiento de San Antonio de Prado Lote o Predio  MIÉRCOLES   1
## 2                         La Candelaria  Tramo de via  MIÉRCOLES   1
## 3                         La Candelaria  Tramo de via  MIÉRCOLES   1
## 4                            El Poblado  Tramo de via  MIÉRCOLES   1
## 5                               Robledo  Tramo de via  MIÉRCOLES   1
## 6                      Laureles Estadio  Interseccion  MIÉRCOLES   1
str(raw_data_2016)
## 'data.frame':    42841 obs. of  19 variables:
##  $ X.U.FEFF.OBJECTID: int  259034 259035 259036 259037 259038 259040 259041 259042 259044 259045 ...
##  $ X                : num  827278 835106 834811 836021 832265 ...
##  $ Y                : num  1175177 1183570 1182025 1178803 1185704 ...
##  $ RADICADO         : num  1519832 1519765 1519752 1519682 1519685 ...
##  $ FECHA            : Factor w/ 366 levels "2016-01-01T00:00:00.000Z",..: 20 20 20 20 20 20 20 20 20 20 ...
##  $ HORA             : Factor w/ 1092 levels "01:00 AM","01:00 PM",..: 918 36 128 696 878 896 778 81 42 452 ...
##  $ DIA              : int  20 20 20 20 20 20 20 20 20 20 ...
##  $ PERIODO          : int  2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 ...
##  $ CLASE            : Factor w/ 8 levels "","Atropello",..: 5 5 5 5 8 5 5 5 5 5 ...
##  $ DIRECCION        : Factor w/ 12962 levels " CR 59 CL 64 -32",..: 9087 3363 7866 6408 11595 11298 1313 78 1793 5222 ...
##  $ DIRECCION_ENC    : Factor w/ 12631 levels "000","CL     053  000 00000",..: 8828 2700 7540 6119 11176 10918 759 284 1275 201 ...
##  $ CBML             : Factor w/ 396 levels "","0","0101",..: 382 197 210 298 122 246 332 298 207 310 ...
##  $ TIPO_GEOCOD      : Factor w/ 2254 levels "Catastro con Interior",..: 5 5 5 5 2013 5 5 2252 5 5 ...
##  $ GRAVEDAD         : Factor w/ 3 levels "HERIDO","MUERTO",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ BARRIO           : Factor w/ 313 levels "","0","6001",..: 56 111 33 175 112 109 242 175 60 97 ...
##  $ COMUNA           : Factor w/ 25 levels "","0","Aranjuez",..: 9 18 18 14 22 19 5 14 18 14 ...
##  $ DISENO           : Factor w/ 13 levels "","Ciclo Ruta",..: 5 11 11 11 11 4 11 4 4 11 ...
##  $ DIA_NOMBRE       : Factor w/ 7 levels "DOMINGO  ","JUEVES   ",..: 5 5 5 5 5 5 5 5 5 5 ...
##  $ MES              : int  1 1 1 1 1 1 1 1 1 1 ...
levels(raw_data_2016$CLASE)
## [1] ""                  "Atropello"         "Caída de Ocupante"
## [4] "Caida Ocupante"    "Choque"            "Incendio"         
## [7] "Otro"              "Volcamiento"
levels(raw_data_2016$CLASE) <- c("Otro","Atropello","Caida_Ocupante","Caida_Ocupante","Choque",
                                 "Incendio","Otro","Volcamiento")
levels(raw_data_2016$CLASE)
## [1] "Otro"           "Atropello"      "Caida_Ocupante" "Choque"        
## [5] "Incendio"       "Volcamiento"

Datos 2017

raw_data_2017 <- read.csv(file="./data/Accidentalidad_georreferenciada_2017.csv", encoding="UTF-8", header=TRUE, sep=",")
head(raw_data_2017)
##   X.U.FEFF.OBJECTID        X       Y RADICADO                    FECHA
## 1            504352 834796.6 1181345  1590356 2017-07-20T00:00:00.000Z
## 2            504353 831461.0 1181883  1586285 2017-06-15T00:00:00.000Z
## 3            504354 833229.3 1186996  1588185 2017-07-02T00:00:00.000Z
## 4            504355 833366.8 1181955  1576853 2017-03-29T00:00:00.000Z
## 5            504356 832577.6 1184274  1591283 2017-07-26T00:00:00.000Z
## 6            504358 834246.7 1180257  1578106 2017-04-12T00:00:00.000Z
##       HORA DIA PERIODO          CLASE         DIRECCION
## 1 08:00 AM  20    2017 Caida Ocupante     CR 43 A CL 33
## 2 04:50 PM  15    2017         Choque       CR 80 CL 33
## 3 04:20 PM   2    2017         Choque     CR 80 CL 80 A
## 4 06:29 PM  29    2017         Choque CL 33 Norte CR 65
## 5 08:10 PM  26    2017      Atropello       CL 50 CR 74
## 6 11:10 AM  12    2017         Choque       CR 48 CL 20
##                DIRECCION_ENC CBML TIPO_GEOCOD   GRAVEDAD
## 1 CR  043 A   033  000 00000 1020  Malla vial     HERIDO
## 2   CR  080   033  000 00000 1109  Malla vial SOLO DAÑOS
## 3 CR  080   080 A  000 00000 0710  Malla vial     HERIDO
## 4   CL  033   065  000 00000 1105  Malla vial SOLO DAÑOS
## 5   CL  050   074  000 00000 1115  Malla vial     HERIDO
## 6   CR  048   020  000 00000 1403  Malla vial SOLO DAÑOS
##               BARRIO           COMUNA       DISENO DIA_NOMBRE MES
## 1          San Diego    La Candelaria Interseccion  JUEVES      7
## 2        Las Acacias Laureles Estadio     Glorieta  JUEVES      6
## 3      López de Mesa          Robledo Tramo de via  DOMINGO     7
## 4 Los Conquistadores Laureles Estadio Tramo de via  MIÉRCOLES   3
## 5     Cuarta Brigada Laureles Estadio Tramo de via  MIÉRCOLES   7
## 6      Villa Carlota       El Poblado Tramo de via  MIÉRCOLES   4
str(raw_data_2017)
## 'data.frame':    42563 obs. of  19 variables:
##  $ X.U.FEFF.OBJECTID: int  504352 504353 504354 504355 504356 504358 504359 504360 504361 504362 ...
##  $ X                : num  834797 831461 833229 833367 832578 ...
##  $ Y                : num  1181345 1181883 1186996 1181955 1184274 ...
##  $ RADICADO         : num  1590356 1586285 1588185 1576853 1591283 ...
##  $ FECHA            : Factor w/ 370 levels "2017-01-01T00:00:00.000Z",..: 201 166 183 88 207 102 154 110 180 174 ...
##  $ HORA             : Factor w/ 1106 levels "01:00 AM","01:00 PM",..: 638 321 278 473 657 950 291 362 203 555 ...
##  $ DIA              : int  20 15 2 29 26 12 3 20 29 23 ...
##  $ PERIODO          : int  2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 ...
##  $ CLASE            : Factor w/ 9 levels "Atropello","Caida Ocupante",..: 2 4 4 4 1 4 2 4 4 4 ...
##  $ DIRECCION        : Factor w/ 12879 levels "CL 1 A CR 70",..: 7319 11494 11596 1612 3122 7985 5410 3656 2392 652 ...
##  $ DIRECCION_ENC    : Factor w/ 12595 levels "000","CL     018  000 00000",..: 7116 11091 11186 1035 2406 7639 4443 2902 1738 5432 ...
##  $ CBML             : Factor w/ 403 levels "","0101","0102",..: 217 230 131 224 239 283 112 212 249 303 ...
##  $ TIPO_GEOCOD      : Factor w/ 2569 levels "Catastro con Interior",..: 5 5 5 5 5 5 5 5 5 4 ...
##  $ GRAVEDAD         : Factor w/ 3 levels "HERIDO","MUERTO",..: 1 3 1 3 1 3 1 1 3 3 ...
##  $ BARRIO           : Factor w/ 325 levels "","6001","9086",..: 252 169 185 195 78 314 134 322 89 135 ...
##  $ COMUNA           : Factor w/ 83 levels "","Alejandro Echavarría",..: 46 55 68 55 55 33 30 46 45 33 ...
##  $ DISENO           : Factor w/ 13 levels "","Ciclo Ruta",..: 4 3 11 11 11 11 5 11 4 4 ...
##  $ DIA_NOMBRE       : Factor w/ 7 levels "DOMINGO  ","JUEVES   ",..: 2 2 1 5 5 5 6 2 2 7 ...
##  $ MES              : int  7 6 7 3 7 4 6 4 6 6 ...
levels(raw_data_2017$CLASE)
## [1] "Atropello"          "Caida Ocupante"     "Caída Ocupante"    
## [4] "Choque"             "Choque "            "Choque y Atropello"
## [7] "Incendio"           "Otro"               "Volcamiento"
levels(raw_data_2017$CLASE) <- c("Atropello","Caida_Ocupante","Caida_Ocupante","Choque","Choque",
                                 "Otro","Incendio","Otro","Volcamiento")
levels(raw_data_2017$CLASE)
## [1] "Atropello"      "Caida_Ocupante" "Choque"         "Otro"          
## [5] "Incendio"       "Volcamiento"
levels(raw_data_2017$CLASE)
## [1] "Atropello"      "Caida_Ocupante" "Choque"         "Otro"          
## [5] "Incendio"       "Volcamiento"
summary(raw_data_2014$CLASE)
##      Atropello Caida_Ocupante         Choque       Incendio           Otro 
##           4779           4157          27157              8           4521 
##    Volcamiento 
##            972
summary(raw_data_2015$CLASE)
##           Otro      Atropello Caida_Ocupante         Choque       Incendio 
##           4219           4485           3691          28249              1 
##    Volcamiento 
##           1435
summary(raw_data_2016$CLASE)
##           Otro      Atropello Caida_Ocupante         Choque       Incendio 
##           4875           4167           3680          28631              4 
##    Volcamiento 
##           1484
summary(raw_data_2017$CLASE)
##      Atropello Caida_Ocupante         Choque           Otro       Incendio 
##           3640           3433          29195           4719              4 
##    Volcamiento 
##           1572
raw_data_2018 <- read.csv(file="./data/Accidentalidad_georreferenciada_2018.csv", encoding="UTF-8", header=TRUE, sep=",")
str(raw_data_2018)
## 'data.frame':    40348 obs. of  19 variables:
##  $ X.U.FEFF.OBJECTID: int  550556 550557 550558 550559 550560 550562 550563 550564 550565 550566 ...
##  $ X                : num  833196 833455 835882 831732 835720 ...
##  $ Y                : num  1184350 1187884 1183347 1180062 1181651 ...
##  $ RADICADO         : int  1612819 1612866 1612809 1612812 1612817 1612856 1612823 1612825 1612850 1612815 ...
##  $ FECHA            : Factor w/ 365 levels "2018-01-01T00:00:00.000Z",..: 14 14 14 14 14 14 14 14 14 14 ...
##  $ HORA             : Factor w/ 1485 levels "01:00 AM","01:00 PM",..: 57 57 168 168 182 222 281 334 348 372 ...
##  $ DIA              : int  14 14 14 14 14 14 14 14 14 14 ...
##  $ PERIODO          : int  2018 2018 2018 2018 2018 2018 2018 2018 2018 2018 ...
##  $ CLASE            : Factor w/ 7 levels "Atropello","Caida Ocupante",..: 4 4 2 6 4 1 4 4 4 2 ...
##  $ DIRECCION        : Factor w/ 12504 levels "CL 1 A CR 25",..: 10404 11159 7325 10853 6620 7455 5569 1588 2214 10721 ...
##  $ DIRECCION_ENC    : Factor w/ 12364 levels "000","CL  001   017  000 00000",..: 10180 10919 6991 10609 6409 7256 5538 1097 1679 10470 ...
##  $ CBML             : Factor w/ 375 levels "","0101","0102",..: 207 103 202 307 172 40 214 194 231 104 ...
##  $ TIPO_GEOCOD      : Factor w/ 2405 levels "Catastro con Interior",..: 5 5 5 5 5 3 5 5 5 5 ...
##  $ GRAVEDAD         : Factor w/ 3 levels "HERIDO","MUERTO",..: 1 3 1 1 3 1 3 3 3 1 ...
##  $ BARRIO           : Factor w/ 321 levels "","0","6001",..: 69 262 192 251 108 205 48 237 200 137 ...
##  $ COMUNA           : Factor w/ 24 levels "","Aranjuez",..: 18 12 17 4 5 19 18 17 16 12 ...
##  $ DISENO           : Factor w/ 13 levels "","Ciclo Ruta",..: 4 11 11 4 11 11 4 5 11 4 ...
##  $ DIA_NOMBRE       : Factor w/ 7 levels "DOMINGO  ","JUEVES   ",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ MES              : int  1 1 1 1 1 1 1 1 1 1 ...
levels(raw_data_2018$CLASE)
## [1] "Atropello"      "Caida Ocupante" "Caída Ocupante" "Choque"        
## [5] "Incendio"       "Otro"           "Volcamiento"
levels(raw_data_2018$CLASE) <- c("Atropello","Caida_Ocupante","Caida_Ocupante","Choque","Incendio","Otro", "Volcamiento")
levels(raw_data_2018$CLASE)
## [1] "Atropello"      "Caida_Ocupante" "Choque"         "Incendio"      
## [5] "Otro"           "Volcamiento"
summary(raw_data_2018$CLASE)
##      Atropello Caida_Ocupante         Choque       Incendio           Otro 
##           3604           3617          28207              7           3739 
##    Volcamiento 
##           1174

Unir los datos

Total_Dataset <- rbind(raw_data_2014,raw_data_2015,raw_data_2016, raw_data_2017, raw_data_2018)
str(Total_Dataset)
## 'data.frame':    209426 obs. of  19 variables:
##  $ X.U.FEFF.OBJECTID: int  211279 211280 211281 211282 211283 211284 211285 211286 211287 211288 ...
##  $ X                : num  831190 835014 837033 830649 833741 ...
##  $ Y                : num  1179690 1184224 1184750 1181383 1188644 ...
##  $ RADICADO         : num  1423828 1423839 1423840 1423849 1423890 ...
##  $ FECHA            : Factor w/ 1831 levels "2014-01-01T00:00:00.000Z",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ HORA             : Factor w/ 2239 levels "01:00 AM","01:00 PM",..: 95 954 1 938 777 201 469 268 37 72 ...
##  $ DIA              : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ PERIODO          : int  2014 2014 2014 2014 2014 2014 2014 2014 2014 2014 ...
##  $ CLASE            : Factor w/ 6 levels "Atropello","Caida_Ocupante",..: 3 1 1 1 2 3 3 3 3 2 ...
##  $ DIRECCION        : Factor w/ 29182 levels "CL 1 A CR 42",..: 11441 8871 6987 1424 11297 8063 3081 6269 11142 8131 ...
##  $ DIRECCION_ENC    : Factor w/ 27999 levels "000","CL     029  000 00000",..: 11024 8642 6786 915 11166 7817 2469 6072 10863 7898 ...
##  $ CBML             : Factor w/ 699 levels "","0101","01010480009",..: 333 192 39 340 105 48 170 176 241 280 ...
##  $ TIPO_GEOCOD      : Factor w/ 5624 levels "Catastro con Interior",..: 2064 5 5 5 5 5 5 5 5 5 ...
##  $ GRAVEDAD         : Factor w/ 3 levels "HERIDO","MUERTO",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ BARRIO           : Factor w/ 340 levels "","6001","Aguas Frias",..: 181 129 201 175 81 40 31 155 294 302 ...
##  $ COMUNA           : Factor w/ 85 levels "","Aranjuez",..: 4 16 18 4 11 2 5 5 17 12 ...
##  $ DISENO           : Factor w/ 13 levels "","Ciclo Ruta",..: 11 11 11 11 11 4 11 4 11 11 ...
##  $ DIA_NOMBRE       : Factor w/ 7 levels "DOMINGO  ","JUEVES   ",..: 5 5 5 5 5 5 5 5 5 5 ...
##  $ MES              : int  1 1 1 1 1 1 1 1 1 1 ...
levels(Total_Dataset$CLASE)
## [1] "Atropello"      "Caida_Ocupante" "Choque"         "Incendio"      
## [5] "Otro"           "Volcamiento"
summary(Total_Dataset$CLASE)
##      Atropello Caida_Ocupante         Choque       Incendio           Otro 
##          20675          18578         141439             24          22073 
##    Volcamiento 
##           6637

La Fecha está cargada como factor, se realiza una transformación a formato de fecha (date)

Total_Dataset$FECHA <- as.Date(Total_Dataset$FECHA, format="%Y-%m-%d")
tail(Total_Dataset)
##        X.U.FEFF.OBJECTID        X       Y RADICADO      FECHA
## 209421            686550 836789.8 1186516  1652251 2018-12-05
## 209422            686551 834601.3 1186742  1652236 2018-12-05
## 209423            686552 832577.7 1183055  1652193 2018-12-05
## 209424            686553 833974.2 1183603  1652324 2018-12-05
## 209425            686554 834299.9 1180877  1652349 2018-12-05
## 209426            686555 836838.6 1186467  1652347 2018-12-05
##                  HORA DIA PERIODO  CLASE     DIRECCION
## 209421 03:20:00 p. m.   5    2018 Choque CR 44 A CL 88
## 209422 03:20:00 p. m.   5    2018 Choque CR 65 CL 91 C
## 209423 03:20:00 p. m.   5    2018 Choque   CL 44 CR 71
## 209424 03:30:00 p. m.   5    2018 Choque   CR 63 CL 50
## 209425 03:40:00 p. m.   5    2018 Choque   CL 27 CR 46
## 209426 04:10:00 p. m.   5    2018   Otro   CR 44 CL 88
##                     DIRECCION_ENC        CBML
## 209421 CR  044 A   088  000 00000 03020770009
## 209422 CR  065   091 C  000 00000        0513
## 209423   CL  044   071  000 00000        1117
## 209424   CR  063   050  000 00000        1101
## 209425   CL  027   046  000 00000        1401
## 209426   CR  044   088  000 00000        0302
##                             TIPO_GEOCOD   GRAVEDAD                BARRIO
## 209421        Nomenclatura con Interior     HERIDO           Las Granjas
## 209422 Malla vial aproximada: CR 65-91A     HERIDO Francisco Antonio Zea
## 209423                       Malla vial SOLO DAÑOS         Florida Nueva
## 209424                       Malla vial     HERIDO    Carlos E. Restrepo
## 209425                       Malla vial SOLO DAÑOS       Barrio Colombia
## 209426                       Malla vial     HERIDO           Las Granjas
##                  COMUNA        DISENO DIA_NOMBRE MES
## 209421         Manrique  Interseccion  MIÉRCOLES  12
## 209422         Castilla  Interseccion  MIÉRCOLES  12
## 209423 Laureles Estadio  Tramo de via  MIÉRCOLES  12
## 209424 Laureles Estadio  Tramo de via  MIÉRCOLES  12
## 209425       El Poblado Lote o Predio  MIÉRCOLES  12
## 209426         Manrique  Interseccion  MIÉRCOLES  12

Se convierten las variables día y mes a factor

Total_Dataset$DIA <- as.factor(Total_Dataset$DIA)
Total_Dataset$MES <- as.factor(Total_Dataset$MES)
tail(Total_Dataset)
##        X.U.FEFF.OBJECTID        X       Y RADICADO      FECHA
## 209421            686550 836789.8 1186516  1652251 2018-12-05
## 209422            686551 834601.3 1186742  1652236 2018-12-05
## 209423            686552 832577.7 1183055  1652193 2018-12-05
## 209424            686553 833974.2 1183603  1652324 2018-12-05
## 209425            686554 834299.9 1180877  1652349 2018-12-05
## 209426            686555 836838.6 1186467  1652347 2018-12-05
##                  HORA DIA PERIODO  CLASE     DIRECCION
## 209421 03:20:00 p. m.   5    2018 Choque CR 44 A CL 88
## 209422 03:20:00 p. m.   5    2018 Choque CR 65 CL 91 C
## 209423 03:20:00 p. m.   5    2018 Choque   CL 44 CR 71
## 209424 03:30:00 p. m.   5    2018 Choque   CR 63 CL 50
## 209425 03:40:00 p. m.   5    2018 Choque   CL 27 CR 46
## 209426 04:10:00 p. m.   5    2018   Otro   CR 44 CL 88
##                     DIRECCION_ENC        CBML
## 209421 CR  044 A   088  000 00000 03020770009
## 209422 CR  065   091 C  000 00000        0513
## 209423   CL  044   071  000 00000        1117
## 209424   CR  063   050  000 00000        1101
## 209425   CL  027   046  000 00000        1401
## 209426   CR  044   088  000 00000        0302
##                             TIPO_GEOCOD   GRAVEDAD                BARRIO
## 209421        Nomenclatura con Interior     HERIDO           Las Granjas
## 209422 Malla vial aproximada: CR 65-91A     HERIDO Francisco Antonio Zea
## 209423                       Malla vial SOLO DAÑOS         Florida Nueva
## 209424                       Malla vial     HERIDO    Carlos E. Restrepo
## 209425                       Malla vial SOLO DAÑOS       Barrio Colombia
## 209426                       Malla vial     HERIDO           Las Granjas
##                  COMUNA        DISENO DIA_NOMBRE MES
## 209421         Manrique  Interseccion  MIÉRCOLES  12
## 209422         Castilla  Interseccion  MIÉRCOLES  12
## 209423 Laureles Estadio  Tramo de via  MIÉRCOLES  12
## 209424 Laureles Estadio  Tramo de via  MIÉRCOLES  12
## 209425       El Poblado Lote o Predio  MIÉRCOLES  12
## 209426         Manrique  Interseccion  MIÉRCOLES  12

Se genera frecuencia que es la tabla a analizar

library(sqldf)
## Loading required package: gsubfn
## Loading required package: proto
## Loading required package: RSQLite
Total_Dataset_Freq <- sqldf("SELECT FECHA, CLASE, count(CLASE) AS FREQ, DIA_NOMBRE, MES, DIA 
       FROM Total_Dataset
       GROUP BY FECHA, CLASE")

se agrega la variable año al datafrate

Total_Dataset_Freq$ANO <- as.factor(format(Total_Dataset_Freq$FECHA,'%Y'))
tail(Total_Dataset_Freq)
##           FECHA          CLASE FREQ DIA_NOMBRE MES DIA  ANO
## 9047 2018-12-30    Volcamiento    2  DOMINGO    12  30 2018
## 9048 2018-12-31      Atropello    8  LUNES      12  31 2018
## 9049 2018-12-31 Caida_Ocupante    6  LUNES      12  31 2018
## 9050 2018-12-31         Choque   50  LUNES      12  31 2018
## 9051 2018-12-31           Otro   10  LUNES      12  31 2018
## 9052 2018-12-31    Volcamiento    2  LUNES      12  31 2018
levels(Total_Dataset_Freq$DIA_NOMBRE)
## [1] "DOMINGO  " "JUEVES   " "LUNES    " "MARTES   " "MIÉRCOLES" "SÁBADO   "
## [7] "VIERNES  "
levels(Total_Dataset_Freq$DIA_NOMBRE) <- c("DOMINGO","JUEVES","LUNES","MARTES","MIERCOLES","SABADO","VIERNES") 
levels(Total_Dataset_Freq$DIA_NOMBRE)
## [1] "DOMINGO"   "JUEVES"    "LUNES"     "MARTES"    "MIERCOLES" "SABADO"   
## [7] "VIERNES"
Total_Dataset_Freq$DIA_NOMBRE <- ordered(Total_Dataset_Freq$DIA_NOMBRE,c("LUNES", "MARTES", "MIERCOLES", "JUEVES", "VIERNES", "SABADO", "DOMINGO"))
levels(Total_Dataset_Freq$DIA_NOMBRE)
## [1] "LUNES"     "MARTES"    "MIERCOLES" "JUEVES"    "VIERNES"   "SABADO"   
## [7] "DOMINGO"

Ahora se agregan otras variables a que caracterizan fechas especiales

Dias_Especiales <- read.csv(file="./data/Caracterizacion.csv", encoding="UTF-8", header=TRUE, sep=";",stringsAsFactors=FALSE)
head(Dias_Especiales)
##        Fecha Lunes martes miercoles jueves viernes sabado domingo Enero
## 1 01-01-2014     0      0         1      0       0      0       0     1
## 2 02-01-2014     0      0         0      1       0      0       0     1
## 3 03-01-2014     0      0         0      0       1      0       0     1
## 4 04-01-2014     0      0         0      0       0      1       0     1
## 5 05-01-2014     0      0         0      0       0      0       1     1
## 6 06-01-2014     1      0         0      0       0      0       0     1
##   Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre
## 1       0     0     0    0     0     0      0          0       0         0
## 2       0     0     0    0     0     0      0          0       0         0
## 3       0     0     0    0     0     0      0          0       0         0
## 4       0     0     0    0     0     0      0          0       0         0
## 5       0     0     0    0     0     0      0          0       0         0
## 6       0     0     0    0     0     0      0          0       0         0
##   Diciembre Feriado Semana.Santa Prima Salondelautomovil Mujer Padre Madre
## 1         0       1            0     0                 0     0     0     0
## 2         0       0            0     0                 0     0     0     0
## 3         0       0            0     0                 0     0     0     0
## 4         0       0            0     0                 0     0     0     0
## 5         0       0            0     0                 0     0     0     0
## 6         0       1            0     0                 0     0     0     0
##   AmoryAmistad
## 1            0
## 2            0
## 3            0
## 4            0
## 5            0
## 6            0
Dias_Especiales <- Dias_Especiales[1:1826,]
Dias_Especiales$FECHA <- as.Date(Dias_Especiales$Fecha, format="%d-%m-%Y")
Dias_Especiales$Fecha <- NULL

Estos días especiales se incorporan al dataframe Total_Dataset_Freq

Total_Dataset_Freq <- sqldf("SELECT * 
              FROM Total_Dataset_Freq
              LEFT JOIN Dias_Especiales USING(FECHA)")
head(Total_Dataset_Freq)
##        FECHA          CLASE FREQ DIA_NOMBRE MES DIA  ANO Lunes martes
## 1 2014-01-01      Atropello   13  MIERCOLES   1   1 2014     0      0
## 2 2014-01-01 Caida_Ocupante    7  MIERCOLES   1   1 2014     0      0
## 3 2014-01-01         Choque   35  MIERCOLES   1   1 2014     0      0
## 4 2014-01-01           Otro   18  MIERCOLES   1   1 2014     0      0
## 5 2014-01-01    Volcamiento    1  MIERCOLES   1   1 2014     0      0
## 6 2014-01-02      Atropello   12     JUEVES   1   2 2014     0      0
##   miercoles jueves viernes sabado domingo Enero Febrero Marzo Abril Mayo
## 1         1      0       0      0       0     1       0     0     0    0
## 2         1      0       0      0       0     1       0     0     0    0
## 3         1      0       0      0       0     1       0     0     0    0
## 4         1      0       0      0       0     1       0     0     0    0
## 5         1      0       0      0       0     1       0     0     0    0
## 6         0      1       0      0       0     1       0     0     0    0
##   Junio Julio Agosto Septiembre Octubre Noviembre Diciembre Feriado
## 1     0     0      0          0       0         0         0       1
## 2     0     0      0          0       0         0         0       1
## 3     0     0      0          0       0         0         0       1
## 4     0     0      0          0       0         0         0       1
## 5     0     0      0          0       0         0         0       1
## 6     0     0      0          0       0         0         0       0
##   Semana.Santa Prima Salondelautomovil Mujer Padre Madre AmoryAmistad
## 1            0     0                 0     0     0     0            0
## 2            0     0                 0     0     0     0            0
## 3            0     0                 0     0     0     0            0
## 4            0     0                 0     0     0     0            0
## 5            0     0                 0     0     0     0            0
## 6            0     0                 0     0     0     0            0

ANALISIS DESCRIPTIVO

library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
plot_ly(data=Total_Dataset_Freq,
        x = ~FECHA,
        y = ~FREQ,
        type = "scatter", mode = "lines",
        split = ~ANO,
         ine=list(width=1))%>%
  layout(title='Accidentes_Medellin',
         xaxis=list(title="Dia"),
         yaxis=list(title="Unidades"))
## Warning: 'scatter' objects don't have these attributes: 'ine'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'selectedpoints', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'stackgroup', 'orientation', 'groupnorm', 'stackgaps', 'text', 'hovertext', 'mode', 'hoveron', 'hovertemplate', 'line', 'connectgaps', 'cliponaxis', 'fill', 'fillcolor', 'marker', 'selected', 'unselected', 'textposition', 'textfont', 'r', 't', 'error_x', 'error_y', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'textpositionsrc', 'rsrc', 'tsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'

## Warning: 'scatter' objects don't have these attributes: 'ine'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'selectedpoints', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'stackgroup', 'orientation', 'groupnorm', 'stackgaps', 'text', 'hovertext', 'mode', 'hoveron', 'hovertemplate', 'line', 'connectgaps', 'cliponaxis', 'fill', 'fillcolor', 'marker', 'selected', 'unselected', 'textposition', 'textfont', 'r', 't', 'error_x', 'error_y', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'textpositionsrc', 'rsrc', 'tsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'

## Warning: 'scatter' objects don't have these attributes: 'ine'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'selectedpoints', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'stackgroup', 'orientation', 'groupnorm', 'stackgaps', 'text', 'hovertext', 'mode', 'hoveron', 'hovertemplate', 'line', 'connectgaps', 'cliponaxis', 'fill', 'fillcolor', 'marker', 'selected', 'unselected', 'textposition', 'textfont', 'r', 't', 'error_x', 'error_y', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'textpositionsrc', 'rsrc', 'tsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'

## Warning: 'scatter' objects don't have these attributes: 'ine'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'selectedpoints', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'stackgroup', 'orientation', 'groupnorm', 'stackgaps', 'text', 'hovertext', 'mode', 'hoveron', 'hovertemplate', 'line', 'connectgaps', 'cliponaxis', 'fill', 'fillcolor', 'marker', 'selected', 'unselected', 'textposition', 'textfont', 'r', 't', 'error_x', 'error_y', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'textpositionsrc', 'rsrc', 'tsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'

## Warning: 'scatter' objects don't have these attributes: 'ine'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'selectedpoints', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'stackgroup', 'orientation', 'groupnorm', 'stackgaps', 'text', 'hovertext', 'mode', 'hoveron', 'hovertemplate', 'line', 'connectgaps', 'cliponaxis', 'fill', 'fillcolor', 'marker', 'selected', 'unselected', 'textposition', 'textfont', 'r', 't', 'error_x', 'error_y', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'textpositionsrc', 'rsrc', 'tsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
plot_ly(data=Total_Dataset_Freq,
        x = ~ANO,
        y = ~FREQ,
        type = "box")%>%
  layout(title='Accidentes_Medellin',
         xaxis=list(title="ano"),
         yaxis=list(title="Unidades"))
plot_ly(data=Total_Dataset_Freq,
        x = ~MES,
        y = ~FREQ,
        type = "box")%>%
  layout(title='Accidentes_Medellin',
         xaxis=list(title="Mes"),
         yaxis=list(title="Unidades"))
plot_ly(data=Total_Dataset_Freq,
        x = ~DIA_NOMBRE,
        y = ~FREQ,
        type = "box")%>%
  layout(title='Accidentes_Medellin',
         xaxis=list(title="Dia_Nombre"),
         yaxis=list(title="Unidades"))

Se observa que excepto el domingo que es menor, los demásla accidentalidad promedio es muy similar, pero se diferencia en la cola derecha de la distribucion

Analisis exploratorio por tipo de accidente

EVALUACIÓN DE MODELOS

ELECCIÓN DEL MODELO